package com.xoms.admin.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.xoms.admin.model.ProviderBean;
import com.xoms.admin.persist.dao.ProviderDao;
import com.xoms.util.StringUtil;
@Repository
public class ProviderImpl extends BaseImpl implements ProviderDao {
	
	
	final String NAME_SPACE = NAME_SPACE_HEADER + ".ProviderMapper";
	
	@Override
	public int selectCount(String key) {
		Map<String, Object> params = new HashMap<String, Object>();
		if (!StringUtil.isEmpty(key)) {
			params.put("key", key);
		}
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount", params);
	}
	
	@Override
	public List<ProviderBean> selectList(String key, int page, int pagesize) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("start", page * pagesize);
		params.put("length", pagesize);
		if (!StringUtil.isEmpty(key)) {
			params.put("key", key);
		}
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", params);
	}

	@Override
	public int del(int pid) {
		return sqlSessionTemplate.delete(NAME_SPACE + ".delete", pid);
	}


	@Override
	public int update(ProviderBean data) {
		return sqlSessionTemplate.update(NAME_SPACE + ".update", data);
	}

	@Override
	public int insert(ProviderBean data) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insert", data);
	}


	@Override
	public ProviderBean selectOneById(int pid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneById", pid);
	}

}
